module wdt(clk,clkwdt,rst,bark,flag,cnt);
  input clk,rst,clkwdt;
  output bark,flag,cnt;
  
  reg cnt_en;                  //计数使能
  reg [4:0]cnt; 
  reg bark;
  reg flag;                    //喂狗标志位

  parameter cnt_full = 12;
  parameter cnt_half = 10;

  always @(posedge clk)begin
    cnt_en = 1;
    cnt = 0;
  end
  always @(negedge clk)begin
    cnt_en = 0;
  end
  
  always @(posedge clkwdt or negedge rst)begin
    flag = 0;
    if(~rst) begin
      cnt <= 0;
      bark <= 0;
    end
    
    else if(cnt_en)begin
      if(cnt == cnt_full) begin
        cnt <= 0;
        bark <= 1;        
      end
    
      else if(cnt == cnt_half) begin
        cnt <= 0;
        bark <= 0;
        flag <= 1;
      end
        
      else if(cnt < cnt_full) begin
        cnt <= cnt + 1;
        bark <= 0;
        flag <= flag;
      end
      
      else begin
        cnt <= cnt;
        bark <= 0;
        flag <= flag; 
      end
   end 
  end                      // always end
endmodule
  
   
    
    